import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/setting/api/settingApi.dart';
import 'package:honeypotflutter/public/public_get.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import 'package:honeypotflutter/publicBussine/bussine_font.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_button.dart';
import 'package:honeypotflutter/publicBussine/view/bussine_card.dart';
import 'package:honeypotflutter/public/views/public_appBar.dart';
import 'package:honeypotflutter/public/public_total.dart';
import 'logic.dart';

class SettingSuggestPage extends StatefulWidget {
  const SettingSuggestPage({Key? key}) : super(key: key);

  @override
  State<SettingSuggestPage> createState() => _SettingSuggestPageState();
}

class _SettingSuggestPageState extends State<SettingSuggestPage> {
  final SettingSuggestLogic logic = Get.put(SettingSuggestLogic());
  final FocusNode _focusNode = FocusNode();
  final TextEditingController _controller = TextEditingController();

  /*
  * 提交按钮
  * */
  clickButton() async {
    if (_controller.text.isEmpty) {
      HLTotal.total("请输入您的意见反馈");
      return;
    }
    SettingApi.suggest("2", _controller.text).then((value) {
      HLGet.back();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: HLAppBar(navigationTitle: "意见反馈"),
      body: MGCard(
        margin: EdgeInsets.only(left: 16, right: 16, top: 16),
        nodeList: [_focusNode],
        children: [
          TextField(
            focusNode: _focusNode,
            controller: _controller,
            style: TextStyle(
              color: MGColors.text1Color,
              fontSize: MGFont.textFont1,
            ),
            decoration: InputDecoration(
                hintText: "请输入您的意见",
                hintStyle: TextStyle(
                  color: MGColors.text3Color,
                  fontSize: MGFont.textFont1,
                ),
                enabledBorder: UnderlineInputBorder(borderSide: BorderSide.none),
                focusedBorder: UnderlineInputBorder(borderSide: BorderSide.none)),
            maxLength: 500,
            maxLines: 12,
          ),
        ],
      ),
      bottomNavigationBar: MGButton(
        title: "提交",
        padding: EdgeInsets.only(left: 30, right: 30, bottom: 30, top: 15),
        buttonAction: clickButton,
      ),
    );
  }

  @override
  void dispose() {
    Get.delete<SettingSuggestLogic>();
    super.dispose();
  }
}
